<template>
<!--  先判断是否接受到了信息再展示-->
  <div class="base-info" v-if="Object.keys(goods).length !== 0">
<!--    商品标题-->
    <div class="info-title">{{goods.title}}</div>

<!--价格部分,新老价格-->
    <div class="info-price">
      <span class="n-price">{{goods.newPrice}}</span>
      <span class="o-price">{{goods.oldPrice}}</span>

      <!--    是否显示优惠活动-->
      <span class="discount"
            v-if="goods.discount" >{{goods.discount}}</span>
    </div>

<!--    销售数据和一个服务-->
    <div class="info-sale">
      <span>{{goods.columns[0]}}</span>
      <span>{{goods.columns[1]}}</span>
      <span>{{goods.services[goods.services.length-1].name}}</span>
    </div>

<!--    售后服务类-->
    <div class="info-service">
<!--      利用v-for展示项目-->
      <span class="info-service-item"
            v-for="index in goods.services.length-1"
            :key="index" >
<!--        因为延误必赔没有icon，所以加了个判断-->
        <img v-if="goods.services[index-1].icon"
             :src="goods.services[index-1].icon">
        <span>{{goods.services[index-1].name}}</span>
      </span>
    </div>

  </div>
</template>

<script>
export default {
  name: "DetailBaseInfo",
  props: {
    goods: {
      type: Object
    }
  }
}
</script>

<style scoped>

  .base-info{
    /*background-color: rgb(80, 229, 248);*/
    margin-top: 15px;
    padding: 0 8px;
    color: #999;
    border-bottom: 5px solid #f2f5f8;
  }

  .info-title{
    color: #222;
    font-size: 17px;

  }

  .info-price{
    margin-top: 10px;

  }

  .info-price .n-price{
    font-size: 24px;
    color: var(--color-high-text);
  }

  .info-price .o-price{
    font-size: 13px;
    margin-left: 10px;
    text-decoration: line-through;
  }

  .info-price .discount{
    font-size: 12px;
    padding: 3px  8px;
    color: #fff;
    background-color: var(--color-high-text);
    border-radius: 8px;
    margin-left: 8px;

    /*让元素上浮一些: 使用相对定位即可*/
    position: relative;
    top: -8px;
  }

  .info-sale{
    margin-top: 15px;

    /*行间距*/
    line-height: 30px;
    display: flex;
    font-size: 13px;
    border-bottom: 1px solid rgba(100,100,100,.1);

    /*好像是两端对齐分布*/
    justify-content: space-between;
  }

  /*.info-sale span{*/
  /*  flex: 1;*/
  /*}*/

  .info-service {
    display: flex;
    justify-content: space-between;
    line-height: 60px;
  }

  .info-service-item img {
    width: 14px;
    height: 14px;
    position: relative;
    top: 2px;
  }

  .info-service-item span {
    font-size: 13px;
    color: #333;
  }

</style>








